home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcplusx.zip / EVENT.CPP < prev    next >
C/C++ Source or Header  |  1991-02-18  |  4KB  |  154 lines

  1. //
  2. // event.cpp    - implementation for class Event
  3. // Author        - Robin W. McKean
  4. // Last Update    - February 17,1991
  5. // Copyright (C) 1991 All rights reserved
  6. // 
  7. // This file remains the property of the author, Robin W. McKean.  You are
  8. // free to use and change it as you see fit.  This module, nor its object
  9. // code, may not however be included  in any packaged software without the
  10. // written consent of the author.
  11. //
  12.  
  13. // Contents ----------------------------------------------------------------
  14. //
  15. //         Event::Event
  16. //        Event::isA
  17. //        Event::nameOf
  18. //        Event::isEqual
  19. //        Event::printOn
  20. //
  21. // Description
  22. //
  23. //      Defines the class Event.  The purpose of this class is to pass
  24. //      information from the program to objects in a uniform manner, no
  25. //        matter what the source of the event.
  26. //            
  27. // End ---------------------------------------------------------------------
  28.  
  29. // Interface dependencies --------------------------------------------------
  30.  
  31. #ifndef _IOSTREAM_H
  32. #include <iostream.h>
  33. #endif
  34.  
  35. #ifndef _USETYPES_H
  36. #include <usetypes.h>
  37. #endif
  38.  
  39. #ifndef _GEN_H
  40. #include <gen.h>
  41. #endif
  42.  
  43. #ifndef _EVENT_H
  44. #include <event.h>
  45. #endif
  46.  
  47. // End Interface dependencies ----------------------------------------------
  48.  
  49. // Member Function //
  50.  
  51. Event::Event( Event& theEvent )
  52.  
  53. // Description -------------------------------------------------------------
  54. //
  55. //         Copies one event into another
  56. //
  57. // Parameters
  58. //
  59. //        Event&
  60. //
  61. //        The event to be copied
  62. //
  63. // End ---------------------------------------------------------------------
  64. {
  65.     type = theEvent.type;
  66.     typeCode = theEvent.typeCode;
  67.     shiftState = theEvent.shiftState;
  68. }
  69.  
  70. // End Event::Event( Event& ) //
  71.  
  72. // Member Function //
  73.  
  74. classType Event::isA( ) const
  75.  
  76. // Description -------------------------------------------------------------
  77. //
  78. //        Returns a value representation of a class
  79. //
  80. // End ---------------------------------------------------------------------
  81. {
  82.     return eventClass;
  83. }
  84.  
  85. // End Event::isA( ) //
  86.  
  87. // Member Function //
  88.  
  89. char *Event::nameOf( ) const
  90.  
  91. // Description -------------------------------------------------------------
  92. //
  93. //        Returns a character representation of a class
  94. //
  95. // End ---------------------------------------------------------------------
  96. {
  97.     return "Event";
  98. }
  99.  
  100. // End Event::nameOf //
  101.  
  102. // Member Function //
  103.  
  104. hashValueType Event::hashValue( ) const
  105.  
  106. // Description -------------------------------------------------------------
  107. //
  108. //        Returns a hash value representation of a class, in this case, there
  109. //        is none, so we return 0.
  110. //
  111. // End ---------------------------------------------------------------------
  112. {
  113.     return hashValueType( 0 );
  114. }
  115.  
  116. // End Event::hashValue //
  117.  
  118. int Event::isEqual( const Object& theEvent ) const
  119.  
  120. // Description -------------------------------------------------------------
  121. //
  122. //        Returns a 1 if this object is equal to the event
  123. //
  124. // End ---------------------------------------------------------------------
  125. {
  126.     return( ( isA() == theEvent.isA() ) &&
  127.             type == ( ( Event& )theEvent ).type &&
  128.             typeCode == ( ( Event& )theEvent ).typeCode &&
  129.             shiftState == ( ( Event& )theEvent ).shiftState );
  130. }
  131.  
  132. // End Event::isEqual //
  133.  
  134. // Member Function //
  135.  
  136. void Event::printOn( ostream& outputStream ) const
  137.  
  138. // Description -------------------------------------------------------------
  139. //
  140. //        Prints the contents of this object to the outputStream
  141. //
  142. // End ---------------------------------------------------------------------
  143. {
  144.     outputStream << "Type: ";
  145.  
  146.     if( type == E_KEY ) outputStream << "Key\n";
  147.     else                outputStream << "Mouse\n";
  148.  
  149.     outputStream << "Code: " << hex << "0x" << typeCode << "\n";
  150.     outputStream << "Shift State: " << "0x" << shiftState << dec << "\n";
  151. }
  152.  
  153. // End Event::printOn //
  154.